home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1999 July
/
Macworld (1999-07).dmg
/
Shareware World
/
Info
/
For Developers
/
Mops 3.4.sea
/
Quick Edit ƒ
/
Subject Glossary
/
Events
< prev
next >
Wrap
Text File
|
1992-11-29
|
10KB
|
264 lines
MOPS WINDOWS and EVENTS
********* IMPORTANT OBJECTS, VECTS, and VALUEs
fevent class event
themouse class mouse
mbaddr class dicaddr will be sent click: messages by fevent
wnd A value, contains the wptr of the window we are looking at.
This will be set by a call to FindWindow in the mousedown
handler or by FrontWindow in the key event handler.
Note that fevent will send messages to this window.
ActW A value, identifies any active active Mops window which should be idled
Will be set to zero if we have, say, a dialog as the front window,
but NOT if we're switched into the background.
SaveActW A value, Saves Actw over suspend/resume.
********** Mops Event Loop Explained
Normally, Mops should be in a loop something like the following if you
want your program to repsond to keyboard input:
BEGIN
key \ key polls events and performs all default behavior
\ while waiting for a key to be pressed
actW
IF
key: actW \ pass keystroke to our window
ELSE
drop \ not our window, so drop the keystroke
THEN
AGAIN ;
But be careful. Once you have put Mops in the above loop you won't be
able to type commands from the console window. Class window, which is
the class of fwind (the console) responds to key: messages by doing
nothing. One solution would be to set a menu handler to grab Mops's
attention by executing SP!. Or one could use Quick Edit, if you are
using System 7, to communicate with Mops even while it is in the
above loop.
From Mike Hore:
actW is the value that "officially" holds the addr of the frontmost Mops
window, or is zero if there isn't one. wnd is just temporary storage. It's
normally the same as actW, but needn't be. If, say, your application has a
"normal" window and also another window with status information or something,
you might not want the status window to become active even if it's clicked on.
But wnd holds the addr of any window clicked on, no matter what. The above
loop will work even if you have no windows open at all.
key is merely doing the following:
key: fevent ( c mods) drop $ ff and ( c' )
fevent is an instance of the EVENT class which is basically an X-ARRAY,
with some additional data and methods, which when sent the key: message
will get the next event from the Mac system and execute the appropriate
handler in fevent. fevent is loaded with 23 event handlers (see file
Objinit) as follows:
event# fevent Mac Toolbox Late Bound
handler equate Messages to wnd
or ActW or mbaddr
------ --------- ----------- -----------------
0 null-evt nullEvt idle: ActW
1 mouse-evt mButDwnEvt content: wnd
click: mbaddr
drag: wnd
grow: wnd
close: wnd
zoom: wnd
2 null-evt mButUpEvt
3 key-evt keyDwnEvt key: mbaddr
4 null-evt keyUpEvt
5 key-evt autoKeyEvt
6 upd-evt updatEvt draw: wnd
7 disk-evt diskInsertEvt
8 actv-evt activateEvt enable: wnd
disable: wnd
9 null-evt not used
10 null-evt networkEvt
11 null-evt ioDrvrEvt
12 null-evt app1Evt
13 null-evt app2Evt
14 null-evt app3Evt
15 null-evt osEvt (was app4Evt) see IM-VI 5-19
enable: wnd
disable: wnd
16 null-evt not used
17 null-evt not used
18 null-evt not used
19 null-evt not used
20 null-evt not used
21 null-evt not used
22 null-evt not used
23 HL-evt kHighLevelEvent see IM-VI 5-21
It is easy to change any of these event handlers at any time, since we can
just define a word, tick its cfa, and store into fevent:
' new-evt-handler 4 to: fevent \ set a handler for key up events
The event handlers in fevent will send late bound messages to wnd.
FEVENT ACTION HANDLERS
-MODELESS --
Sets normal event handling - no modeless dialogs, by storing the appropriate 23
event handlers in the event object fevent.
ACTV-EVT -- false
Handles activate and deactivate events by sending a late bound
enable:and disable: messages to the current window (but only if it is an
application window).
DISK-EVT -- false Handles a disk insert event.
HL-EVT -- falseHandles High-level events. Several vects are involved.
KEY-EVT -- keywd modswd T | -- F
Gets key value if true. Handles command-key menu actions. Does not
handle "normal" key actions, that is up to your code.
MOUSE-EVT -- false Handles mouse events.
NULL-EVT -- false
Will send late bound idle: to the actW, if it is non-zero.
OS-EVT -- false Handles operating system events by calling various vects.
UPD-EVT -- false
Handles update events by sending a late bound draw: message to the
current window (but only if it is an application window).
APPWIND? -- b
True if this is an application window. This check is necessary for
non-multifinder systems while calling WaitNextEvent.
KEY -- c
A system vector. The action of key is normally (key). (key!) is used
to set the default action for key.
(KEY!) --
Sets the default action for vect key by storing the cfa of (key) in it.
(KEY) -- c
The default action for key. c is the character corresponding to the key
that was pressed. : (key) key: fevent drop $ FF and ;
(PAUSE) -- Our standard action for the vect pause.
?EVENT eventMask -- b
Calls the Toolbox Event Manager routine EventAvail to test for the
event(s) specified by eventMask. If an event is available, leaves a
true flag; otherwise, leaves a false flag.
?PAUSE --
?TERMINAL --
Performs a 40 ?Event. This word is used in class Mouse, and in the
utility word ?pause to test for a keyboard event.
APPLE EVENTS
(AEErr) err# --
Default for error returns from AppleEvent handlers, i.e. this is the
action for AEErrorVec.
AEErrorVec --
A vect. Called when an AppleEvent handler returns. Default is (AEerr).
AEhandler ^AE ^AEReply RefCon --
Put at the start of an AppleEvent handler proc. Pops the parms into the
appropriate locations.
AppleEvents? -- b
A value. Set True by the startup code if AppleEvents are available.
?RTNAEPMISSED w:xx rc -- w:rc'
This can be called after calling GotParms? to convert the return code
from that word to the appropriate return code to return to the caller of
the handler. If GotParms? returns false, that means we missed a parm,
so we return -1715. If GotParms? returned anything non-zero, that means
we got all the parms, so we return zero.
doAEhandler ^AE ^AEReply RefCon --
Called from AEhandler to set things up at the start of a handler.
FAE -- ^AE A value used to handle AppleEents.
HLEventVEC --
A vect. Called for generic high-level events. Default is vfalse.
MISCELLANEOUS
#docsToOpen -- n A value.
BECOME -- : word
BECOME allows restarting at a given word, with all stacks empty. This
is necessary in menu handlers and other areas that could create
indefinite nesting situations.
CvtClip -- A vect. Called for clip conversion.
DBLTICKS -- n
Returns the double-click interval in ticks via the Mac global variable
DoubleTime.
DESK -- Desktop click handler - do nothing.
FIND-WINDOW Tpoint -- region ^window
Calls the Window Manager routine FindWindow to find the window in which
a mouse-down event occurred at Tpoint, a Toolbox point in global
coordinates. Leaves the region of the window in which the mouse-down
occurred and ^window, the pointer to the window object's private data.
GOTPARMS? -- rc
This can be called at the end of a handler, to check if we got all the
parameters.
MouseMoved -- A vect. Called for mouse moved.
NEXTEVENT ^event mask -- b
We call WaitNextEvent if it's available, otherwise GetNextEvent.
NEXT_TASK --
A vect. If multitasking is installed, this will be redirected to do a
task switch.
OpenAppVec -- code True | -- False
As set up in Mops, OpenAppVec simply returns False and does nothing
else.
OpenDocHandler ?
Normal :PROC entry sequence to set up the Mops addressing environment
OpenDocVec -- code True | -- False
OpenDocVec finds the number of files in the given list of files, and
puts the number in the value #DocsToOpen. It then handles each file in
the given list fFcb, then calling the sufficient for your appropriately.
OpenMopsDic ? OpenMopsDic is the default for OpenDocVec.
PAUSE --
A system vector, normally contains (pause), defined in file Frontend.
PAUSE should be called at strategic intervals in all applications,
unless Key is being called frequently. Pause normally calls next:
fEvent which allows a task switch to be done under MultiFinder, and
which also handles any pending events for this task, such as window
updates. Remember to disable any menus etc. that you don't want to
execute in this situation! Unexpected re-entrancy is a good way to bomb!
PrintDocHandler ?
Normal :PROC entry sequence to set up the Mops addressing environment
QuitAppHandler ?
Normal :PROC entry sequence to set up the Mops addressing environment
QuitAppVec -- code True | -- False
The current setting for QuitAppVec is simply to call BYE. Your
application will probably want to do something a bit more intelligent.
Read1DocVec -- code True | -- False
As set up, Read1DocVec assumes the file is a Mops dictionary.
Read1DocVec must point to a routine which will read the file designated
by the file object fFcb, close it, and return a result on the stack.
True indicates the OpenDocVec loop can continue. False means the loop
must terminate. You could return False, for example, on an error, or
simply if your application can't accept more than one document open at a
time.
RESUME? -- b A value. True if we've just received a Resume event.
ResumeVec -- A vect. Called for resume.
SaveActW -- wptr Saves actW over Suspend-Resume.
SLEEPTICKS -- n
A value. Used in calls to WaitNextEvent. Default is 20 as set by file
Frontend.
STILLDOWN? -- b
A direct call to StillDown. Returns true if mouse button is still down.
SUSPEND? -- b
A value. True if we've just received a Suspend event.
SuspendVec -- A vect. Called for suspend.
SYS wptr -- System click handler, a direct call to SystemClick.
THEDLG -- addr A variable.
THEPOINT -- addr A variable.
WAITCLICK -- Waits until a mouse click or key event.
WHRFEV -- point Will become where: fEvent .
WNEavail? -- b
A value. Set True by the startup code if the WaitNextEvent trap is
available in the System being used.